//package com.imay.live.view.custom;
//
//import android.content.Context;
//import android.support.design.widget.CoordinatorLayout;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.util.AttributeSet;
//import android.view.MotionEvent;
//import android.view.View;
//
//import com.imay.live.R;
//import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
//
///**
// * Created by liangzhenxiong on 2017/04/12 0012.
// */
//
//public class ScrollingViewBehavior extends android.support.design.widget.AppBarLayout.ScrollingViewBehavior {
//    TwinklingRefreshLayout mRefreshLayout;
//
//    public ScrollingViewBehavior(Context context, AttributeSet attrs) {
//        super(context, attrs);
//    }
//
//    public void setmRefreshLayout(TwinklingRefreshLayout mRefreshLayout) {
//        this.mRefreshLayout = mRefreshLayout;
//    }
//
//    @Override
//    public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {
//        final RecyclerView recyclerView = (RecyclerView) directTargetChild.findViewById(R.id.rcv_content);
//        if (recyclerView != null) {
//            recyclerView.setOnTouchListener(new View.OnTouchListener() {
//                @Override
//                public boolean onTouch(View v, MotionEvent event) {
//                    if (event.getAction() == MotionEvent.ACTION_UP) {
//                        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
//                        if (layoutManager instanceof LinearLayoutManager) {
//                            int index = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
//                            mRefreshLayout.setEnableRefresh(index == 0);
//                        }
//
//                    }
//                    return false;
//                }
//            });
//        }
//        return true;
//    }
//
//
//}
